package com.cmwa.solution.business.investmentResearch.service.impl;

import javax.annotation.Resource;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.cmwa.solution.business.investmentResearch.dao.InvestmentResearchDao;
import com.cmwa.solution.business.investmentResearch.service.InvestmentResearchService;
import com.cmwa.solution.sys.attach.service.AttachService;
import com.cmwa.solution.utils.SessionUtils;
import com.cmwa.solution.business.investmentResearch.entity.InvestmentResearchVo;

import java.util.List;

import com.cmwa.solution.base.entity.Employee;
import com.cmwa.solution.base.entity.Page;
import com.cmwa.solution.base.entity.SearchParam;

/**
 * 投资研究业务实现层
 * 
 * @author ex-sujh
 * @date 2019-02-14 09:42:22
 */
@Service
public class InvestmentResearchServiceImpl implements InvestmentResearchService {
	@Resource
	private InvestmentResearchDao investmentResearchDao;
	@Resource
	private AttachService attachService;
	
		
	@Override
	public void insertInvestmentResearch(InvestmentResearchVo investmentResearch) {
		investmentResearchDao.insertInvestmentResearch(investmentResearch);
	}
	
		
		
	@Override
	public void physicDeleteInvestmentResearchById(String id) {
		investmentResearchDao.physicDeleteInvestmentResearchById(id);
	}
	
		
		
	@Override
	public void logicDeleteInvestmentResearchById(String id) {
		investmentResearchDao.logicDeleteInvestmentResearchById(id);
	}
	
		
		
	@Override
	public void updateInvestmentResearchById(InvestmentResearchVo investmentResearch) {
		investmentResearchDao.updateInvestmentResearchById(investmentResearch);
	}
	
		
		
	@Override
	public Page<InvestmentResearchVo> investmentResearchListPage(SearchParam sp) {
		List<InvestmentResearchVo> items = investmentResearchDao.investmentResearchListPage(sp);
		return Page.create(items, sp.getStart(), sp.getLimit(), sp.getTotal());
	}
	
		
		
	@Override
	public InvestmentResearchVo getInvestmentResearchById(String id) {
		return investmentResearchDao.getInvestmentResearchById(id);
	}



	@Override
	public void saveInvestmentResearch(InvestmentResearchVo investmentResearchVo, String attIds) {
		Employee employee = SessionUtils.getEmployee();
		investmentResearchVo.setCreateId(employee.getID());
		investmentResearchDao.insertInvestmentResearch(investmentResearchVo);
		if (StringUtils.isNotEmpty(attIds)) {
			attachService.addAttachRel2(employee.getID(), investmentResearchVo.getId(), "INVESTMENT_RESEARCH", attIds);
		}
	}
	
		
	
}
